package com.tbit.uqbike.center.service.impl;

import com.tbit.uqbike.center.dao.core.BatteryBmsDao;
import com.tbit.uqbike.center.dao.log.BmsBatteryDao;
import com.tbit.uqbike.center.pojo.Battery;
import com.tbit.uqbike.center.pojo.BmsAbnormal;
import com.tbit.uqbike.center.service.BatteryBmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 15:38 2022/7/29
 */
@Service
public class BatteryBmsServiceImpl implements BatteryBmsService {
    @Autowired
    private BatteryBmsDao batteryBmsDao;
    @Autowired
    private BmsBatteryDao bmsBatteryDao;

    @Override
    public List<Battery> getByMachineId() {

        return batteryBmsDao.getByMachineId();
    }

    @Override
    public Integer getAccountId(Integer machineId) {
        return batteryBmsDao.getAccountId(machineId);
    }

    @Override
    public void edit(Integer abnormalType, Integer adAccountId, String batteryNO) {
        Map<String, Object> map = new HashMap<>();
        map.put("abnormalType", abnormalType);
        map.put("adAccountId", adAccountId);
        map.put("batteryNO", batteryNO);
        batteryBmsDao.edit(map);
    }

    @Override
    public void add(BmsAbnormal bmsAbnormal) {
        bmsAbnormal.setAddTime(new Date());
        bmsBatteryDao.add(bmsAbnormal);
    }

    @Override
    public int getExist(Integer abnormalType, Integer adAccountId, String batteryNO) {
        Map<String, Object> map = new HashMap<>();
        map.put("abnormalType", abnormalType);
        map.put("adAccountId", adAccountId);
        map.put("batteryNO", batteryNO);
        return bmsBatteryDao.getExist(map);
    }
}
